//
//  HomeTableViewCell.swift
//  ams
//
//  Created by coterjiesen on 2017/5/11.
//  Copyright © 2017年 coterjiesen. All rights reserved.
//

import UIKit

class HomeTableViewCell:UITableViewCell{

    // 标题
    var titleLabel: UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()
    // 值
    var valueLabel: UILabel = {
        let label = UILabel()
        label.font = v2Font(16)
        return label;
    }()
    /// 装上面定义的那些元素的容器
    var contentPanel:UIView = UIView()
    
    let putaway: UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()
    let putaway_v : UILabel = {
        let label = UILabel()
        label.font = v2Font(20)
        return label;
    }()
    let putout  : UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()

    let putout_v  : UILabel = {
        let label = UILabel()
        label.font = v2Font(20)
        return label;
    }()

    let scrap : UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()

    let scrap_v : UILabel = {
        let label = UILabel()
        label.font = v2Font(20)
        return label;
    }()

    let repair: UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()

    let repair_v : UILabel = {
        let label = UILabel()
        label.font = v2Font(20)
        return label;
    }()

    let netIn : UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()

    let netIn_v : UILabel = {
        let label = UILabel()
        label.font = v2Font(20)
        return label;
    }()

    let total : UILabel = {
        let label = UILabel()
        label.font = v2Font(14)
        return label;
    }()


    let total_v : UILabel = {
        let label = UILabel()
        label.font = v2Font(20)
        return label;
    }()


    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier);
        self.setup();
    }
    func setup(){
        self.backgroundColor = UIColor.clear
        self.selectionStyle = .none
        
        contentPanel.layer.cornerRadius = 5
        contentPanel.backgroundColor = CuColor.colors.v2_backgroundColor
        putaway.text = "入库数量"
        putout.text = "出库数量"
        scrap.text = "报废数量"
        repair.text = "返修数量"
        netIn.text = "入网数量"
        total.text = "总库存"
        contentPanel.addSubview(total)
        contentPanel.addSubview(netIn)
        contentPanel.addSubview(repair)
        contentPanel.addSubview(scrap)
        contentPanel.addSubview(putout)
        contentPanel.addSubview(putaway)
        contentPanel.addSubview(putaway_v)
        contentPanel.addSubview(putout_v)
        contentPanel.addSubview(scrap_v)
        contentPanel.addSubview(repair_v)
        contentPanel.addSubview(netIn_v)
        contentPanel.addSubview(total_v)
        self.contentView.addSubview(contentPanel)
        self.setupLayout()
        self.thmemChangedHandler = {[weak self] (style) -> Void in
            self?.contentPanel.backgroundColor = CuColor.colors.v2_CellWhiteBackgroundColor
            self?.putaway.textColor = CuColor.colors.v2_TopicListUserNameColor;
            self?.putout.textColor=CuColor.colors.v2_TopicListUserNameColor;
            self?.scrap.textColor = CuColor.colors.v2_TopicListUserNameColor
            self?.repair.textColor = CuColor.colors.v2_TopicListUserNameColor
            self?.total.textColor=CuColor.colors.v2_TopicListUserNameColor;
        }
    }
    func setupLayout(){
        contentPanel.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView).offset(6)
            make.right.equalTo(self.contentView).offset(-6)
            make.top.equalTo(self.contentView).offset(3)
            make.bottom.equalTo(self.contentView).offset(-3)
        }
        putaway.snp.makeConstraints{(make)->Void in
            make.left.top.equalTo(self.contentPanel).offset(12);
            make.height.equalTo(16);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        putaway_v.text = "0"
        putaway_v.snp.makeConstraints{(make)->Void in
            make.left.equalTo(self.putaway)
            make.top.equalTo(self.putaway.snp.bottom);
            make.height.equalTo(40);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        putout.snp.makeConstraints{(make)->Void in
            make.top.equalTo(self.contentPanel).offset(12);
            make.left.equalTo(self.putaway.snp.right)
            make.height.equalTo(16);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        putout_v.text = "0"
        putout_v.snp.makeConstraints{(make)->Void in
            make.left.equalTo(self.putout)
            make.top.equalTo(self.putout.snp.bottom);
            make.height.equalTo(40);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        scrap.snp.makeConstraints{(make)->Void in
            make.top.equalTo(self.contentPanel).offset(12);
            make.left.equalTo(self.putout.snp.right)
            make.height.equalTo(16);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        scrap_v.text = "0"
        scrap_v.snp.makeConstraints{(make)->Void in
            make.left.equalTo(self.scrap)
            make.top.equalTo(self.scrap.snp.bottom);
            make.height.equalTo(40);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        repair.snp.makeConstraints{(make)->Void in
            make.top.equalTo(self.putaway_v.snp.bottom).offset(12);
            make.left.equalTo(self.putaway)
            make.height.equalTo(16);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        repair_v.text = "0"
        repair_v.snp.makeConstraints{(make)->Void in
            make.left.equalTo(self.repair)
            make.top.equalTo(self.repair.snp.bottom);
            make.height.equalTo(40);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        netIn.snp.makeConstraints{(make)->Void in
            make.top.equalTo(self.repair)
            make.left.equalTo(self.putout)
            make.height.equalTo(16);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        netIn_v.text = "0"
        netIn_v.snp.makeConstraints{(make)->Void in
            make.left.equalTo(self.netIn)
            make.top.equalTo(self.netIn.snp.bottom);
            make.height.equalTo(40);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        total.snp.makeConstraints{(make)->Void in
            make.top.equalTo(self.repair)
            make.left.equalTo(self.scrap)
            make.height.equalTo(16);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
        total_v.text = "0"
        total_v.snp.makeConstraints{(make)->Void in
            make.left.equalTo(self.total)
            make.top.equalTo(self.total.snp.bottom);
            make.height.equalTo(40);
            make.width.equalTo(SCREEN_WIDTH/3);
        }
    }
    func bind(){
        putaway_v.text = CuUser.sharedInstance.user?.putaway
        putout_v.text = CuUser.sharedInstance.user?.putout
        scrap_v.text = CuUser.sharedInstance.user?.scrap
        repair_v.text = CuUser.sharedInstance.user?.repair
        netIn_v.text = CuUser.sharedInstance.user?.netIn
        total_v.text = CuUser.sharedInstance.user?.putaway
        print("lodingdata")
    }
}
